package com.kaishengit.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kaishengit.dao.IdeacommentDao;
import com.kaishengit.pojo.Idea;
import com.kaishengit.pojo.Ideacomment;
import com.kaishengit.pojo.User;
import com.kaishengit.util.DateUtil;

@Service
@Transactional
public class IdeacommentService {
	private IdeacommentDao ideacommentDao;
	
	public void save(Ideacomment ideacomment){
		ideacommentDao.save(ideacomment);
	}
	
	public void save(Ideacomment ideacomment, User user, Idea idea) {
		ideacomment.setCreatetime(DateUtil.getDate());
		ideacomment.setUser(user);
		ideacomment.setIdea(idea);
		ideacommentDao.save(ideacomment);
	}
	public void update(Ideacomment ideacomment, User user, Idea idea) {
		ideacomment.setCreatetime(DateUtil.getDate());
		ideacomment.setUser(user);
		ideacomment.setIdea(idea);
		ideacommentDao.update(ideacomment);
	}
	public void updaate(Ideacomment ideacomment){
		ideacommentDao.update(ideacomment);
	}
	
	public void del(int id){
		ideacommentDao.del(id);
	}
	
	public Ideacomment findById(int id){
		return ideacommentDao.findById(id);
	}
	
	public List<Ideacomment> findAll(){
		return ideacommentDao.findAll();
	}
	
	@Autowired
	public void setIdeacommentDao(IdeacommentDao ideacommentDao) {
		this.ideacommentDao = ideacommentDao;
	}

	public List<Ideacomment> findByIdeaId(Idea idea) {
		return ideacommentDao.findByIdeaId(idea);
	}

}
